import { GBox } from "../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { OperateMarryItem } from "./OperateMarryItem";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
//class OperateMarryItemBox
    
    export  class OperateMarryItemBox extends GBox
    {
        constructor()
        {
            super();
            this.direction = GBoxDirection.HORIZONTAL;
            this.mouseEnabled = false;
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            var loc1=null;
            while (numChildren > 0) 
            {
                loc1 = removeChildAt(0) as OperateMarryItem;
                loc1.dispose();
                ObjectPool.disposeObject(loc1);
            }
            return;
        }

        protected /* override */ resetPosition(): void
        {
            var loc1=0;
            var loc4=null;
            var loc2=0;
            var loc3=this.numChildren;
            if (this.direction != GBoxDirection.VERTICAL) 
            {
                if (this.direction == GBoxDirection.HORIZONTAL) 
                {
                    loc1 = 0;
                    while (loc1 < loc3) 
                    {
                        (loc4 = this.getChildAt(loc1)).x = loc2;
                        if (loc1 != 0) 
                        {
                            loc4.x = loc4.x + horizontalGap;
                        }
                        loc4.y = 0;
                        loc2 = loc4.x + loc4.width;
                        ++loc1;
                    }
                }
            }
            else 
            {
                loc1 = 0;
                while (loc1 < loc3) 
                {
                    (loc4 = this.getChildAt(loc1)).x = 0;
                    loc4.y = loc2;
                    if (loc1 != 0) 
                    {
                        loc4.y = loc4.y + verticalGap;
                    }
                    loc2 = loc4.y + loc4.height;
                    ++loc1;
                }
            }
            return;
        }

        public /* override */ get height(): number
        {
            if (this.numChildren > 0) 
            {
                return getChildAt(0).height;
            }
            return super.height;
        }
    }
